package com.zyh.system.supermarket.domain;

/**
 * @Author zyh
 * @Date 2024/8/3 14:28
 * @Description 超市会员信息类
 */

public class UserInfo implements Comparable<UserInfo> {

    private String userName;
    private String cardType;
    private Integer score;
    private UserState state;//卡片状态

    public UserInfo() {
    }

    public UserInfo(String userName, String cardType, Integer score, UserState state) {
        this.userName = userName;
        this.cardType = cardType;
        this.score = score;
        this.state = state;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getCardType() {
        return cardType;
    }

    public void setCardType(String cardType) {
        this.cardType = cardType;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    public UserState getState() {
        return state;
    }

    public void setState(UserState state) {
        this.state = state;
    }

    @Override
    public String toString() {
        return "UserInfo{" +
                "userName='" + userName + '\'' +
                ", cardType=" + cardType +
                ", score=" + score +
                ", state=" + state +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserInfo userInfo = (UserInfo) o;

        if (userName != null ? !userName.equals(userInfo.userName) : userInfo.userName != null) return false;
        if (cardType != userInfo.cardType) return false;
        if (score != null ? !score.equals(userInfo.score) : userInfo.score != null) return false;
        return state == userInfo.state;
    }

    @Override
    public int hashCode() {
        int result = userName != null ? userName.hashCode() : 0;
        result = 31 * result + (cardType != null ? cardType.hashCode() : 0);
        result = 31 * result + (score != null ? score.hashCode() : 0);
        result = 31 * result + (state != null ? state.hashCode() : 0);
        return result;
    }

    //根据id从大到小排序
    @Override
    public int compareTo(UserInfo o) {
        if (this.getUserName().compareTo(o.getUserName()) > 0) {
            return -1;
        } else if (this.getUserName().compareTo(o.getUserName()) < 0) {
            return 1;
        } else {
            return 0;
        }
    }
}
